from typing import List, Optional
from pydantic import BaseModel, EmailStr, Field
from datetime import datetime

# 用户基础模式
class UserBase(BaseModel):
    username: str
    email: EmailStr
    full_name: Optional[str] = None
    avatar: Optional[str] = None
    bio: Optional[str] = None

# 创建用户
class UserCreate(UserBase):
    password: str
    status: Optional[str] = "active"

# 更新用户
class UserUpdate(BaseModel):
    full_name: Optional[str] = None
    avatar: Optional[str] = None
    bio: Optional[str] = None
    email: Optional[EmailStr] = None
    password: Optional[str] = None
    status: Optional[str] = None

# 用户认证
class UserAuth(BaseModel):
    username: str
    password: str

# 用户简要信息（用于列表展示）
class UserBrief(BaseModel):
    id: int
    username: str
    full_name: Optional[str] = None
    avatar: Optional[str] = None
    
    class Config:
        orm_mode = True

# 完整用户信息
class User(UserBase):
    id: int
    status: Optional[str] = "active"
    is_active: bool
    is_verified: bool
    created_at: datetime
    updated_at: Optional[datetime] = None
    
    class Config:
        orm_mode = True

# 用户带统计信息
class UserWithStats(User):
    post_count: int = 0
    follower_count: int = 0
    following_count: int = 0
    
    class Config:
        orm_mode = True

# 令牌
class Token(BaseModel):
    access_token: str
    token_type: str

# 令牌数据
class TokenData(BaseModel):
    username: Optional[str] = None 